import { BaseCommand } from "./BaseCommand";
import { API_EVENT, COMMAND_STATUS } from "@/FrontProcessing/interface";
/**
 * Cmd_Meshextrude2d
 * @description 二维拉伸
 */
export class Cmd_Meshextrude2d_Clear extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_CLEAR;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.meshextrude2d_clear(this.params).then((result) => {
        console.log("==== Cmd_Meshextrude2d_Clear result: ", result);
        this.status = COMMAND_STATUS.FINISHED;
        resolve(result);
      });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude2d_Leave extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_LEAVE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.meshextrude2d_leave(this.params).then((result) => {
        console.log("==== Cmd_Meshextrude2d_Leave result: ", result);
        this.status = COMMAND_STATUS.FINISHED;
        resolve(result);
      });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude2d_Update_Method extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_UPDATE_METHOD;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.meshextrude2d_update_method(this.params).then((result) => {
        console.log("==== Cmd_Meshextrude2d_Update_Method result: ", result);
        this.status = COMMAND_STATUS.FINISHED;
        resolve(result);
      });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude2d_Preview extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_PREVIEW;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.meshextrude2d_preview({ ...this.params }).then((result) => {
        console.log("==== Cmd_Meshextrude2d_Preview result: ", result);
        this.status = COMMAND_STATUS.FINISHED;
        resolve(result);
      });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude2d_Create extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_CREATE;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system.meshextrude2d_create({ ...this.params }).then((result) => {
        console.log("==== Cmd_Meshextrude2d_Create result: ", result);
        this.status = COMMAND_STATUS.FINISHED;
        resolve(result);
      });
    });
  }

  undo(): boolean {
    return false;
  }
}
export class Cmd_Meshextrude2d_Add_Entity extends BaseCommand {
  event = API_EVENT.MESHEXTRUDE2D_ADD_ENTITY;
  execute(): Promise<boolean> {
    this.system.history.push(this);
    return new Promise((resolve, reject) => {
      this.status = COMMAND_STATUS.RUNNING;
      this.system
        .meshextrude2d_add_entity(this.params)
        .then((result) => {
          this.status = COMMAND_STATUS.FINISHED;
          resolve(result);
        })
        .catch((err) => {
          reject(err);
        });
    });
  }

  undo(): boolean {
    return false;
  }
}
